<template>
    <div id="customersAdd">
        <div class="form-left">
            <h1>新增用户</h1>
            <p>新增数据</p>
            <div class="col">
                <label>用户姓名：</label
                ><input type="text" v-model="customer.name" />
            </div>
            <div class="col">
                <label>用户电话：</label
                ><input type="text" v-model="customer.phone" />
            </div>
            <div class="col">
                <label>用户密码：</label
                ><input type="text" v-model="customer.password" />
            </div>
            <div><button @click="customersAdd(customer)">确认添加</button></div>
        </div>
    </div>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const { mapActions } = createNamespacedHelpers("customers");
const { mapState } = createNamespacedHelpers("salesmansLogin");
export default {
    data() {
        return {
            customer: {
                name: "",
                password: "",
                phone: "",
                salesmansId: "",
            },
        };
    },
    created() {
        this.changeSalesmansId();
    },
    computed: {
        ...mapState(["salesmans_Id"]),
    },
    methods: {
        ...mapActions(["customersAdd"]),
        changeSalesmansId() {
            this.customer.salesmansId = localStorage.salesmansId;
        },
    },
};
</script>

<style lang="scss">
#customersAdd {
    margin: 60px 0 0 100px;
    .form-left {
        float: left;
        h1 {
            font-size: 30px;
            margin: 20px 0;
        }
        p {
            margin: 15px 0;
        }
        .col {
            margin: 20px 0;
        }
    }
    .img-right {
        float: left;
        margin: 100px 0 0 150px;
    }
    .avatar-uploader .el-upload {
        border: 1px dashed #d9d9d9;
        border-radius: 6px;
        cursor: pointer;
        position: relative;
        overflow: hidden;
    }
    .avatar-uploader .el-upload:hover {
        border-color: #409eff;
    }
    .avatar-uploader-icon {
        font-size: 28px;
        color: #8c939d;
        width: 178px;
        height: 178px;
        line-height: 178px;
        text-align: center;
    }
    .avatar {
        width: 178px;
        height: 178px;
        display: block;
    }
}
</style>